<?php
// namespace demo;
/**
 *
 * @authors  Ysg (y.shi.guo@gmail.com)
 * @website  http://ysg.bonza.cn
 * @date     2017-07-24 11:43:02
 */

header("Content-type:text/html;charset:utf8;");
header("Pragma: no-cache");
header("Pragma: no-cache");

date_default_timezone_set('PRC');

define("ROOT_PATH",realpath('.'));




/*$subject = array('1', 'a', '2', 'b', '3', 'A', 'B', '4');
$pattern = array('/\d/', '/[a-z]/', '/[1a]/');
$replace = array('A:$0', 'B:$0', 'C:$0');

echo "preg_filter 返回值：\n";
print_r(preg_filter($pattern, $replace, $subject));

echo "preg_replace 返回值：\n";
print_r(preg_replace($pattern, $replace, $subject));*/

/*$array = array(1, 2, 3.4, 53, 7.9,0.9);
// 返回所有包含浮点数的元素
$fl_array = preg_grep("/^(\d+)?\.\d+$/", $array);
print_r($fl_array);
*/

//在这个例子中，preg_quote($word) 用于保持星号原文涵义，使其不使用正则表达式中的特殊语义。

$textbody = "This book is *very* difficult to find.";
$word = "*very*";
$textbody = preg_replace ("/" . preg_quote($word) . "/",
                          "<i>" . $word . "</i>",
                          $textbody);
echo $textbody;















